package com.hsp.learn.search;

/**
 * @Author Zan
 * @Create 2024/10/8 11:52
 * @ClassName: SeqSearch
 * @Description : 查找算法
 */
public class SeqSearch {
    public static void main(String[] args) {
        int[] arr = {1, 9, 11, -1, 34, 89};
        int index = seqSearch(arr, 11);
        if (index == -1) {
            System.out.println("没有查找到");
        } else {
            System.out.println("找到了 " + index);
        }
    }

    public static int seqSearch(int[] arr, int target) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == target) {
                return i;
            }
        }
        return -1;
    }
}
